package com.rp.common.utils;

import com.rp.data.tcp_ws.server_ws.ServerHandlerWs;
import io.netty.channel.Channel;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;


public class GetChanelById {
    public static ArrayList<Channel> byUserId(String id){
        ArrayList<Channel> list = new ArrayList<>();
        Iterator<Map.Entry<Channel, String>> iterator = ServerHandlerWs.channelUserMap.entrySet().iterator();
        while (iterator.hasNext()){
            Map.Entry<Channel, String> next = iterator.next();
            if(next.getValue().equals(id)){
                list.add(next.getKey());
            }
        }
        return list;
    }
    public static ArrayList<Channel> bySubjectId(String id){
        ArrayList<Channel> list = new ArrayList<>();
        Iterator<Map.Entry<Channel, String>> iterator = ServerHandlerWs.channelSubjectMap.entrySet().iterator();
        while (iterator.hasNext()){
            Map.Entry<Channel, String> next = iterator.next();
            if(next.getValue().equals(id)){
                list.add(next.getKey());
            }
        }
        return list;
    }
    public static ArrayList<Channel> bySvg(String id){
        ArrayList<Channel> list = new ArrayList<>();
        Iterator<Map.Entry<Channel, String>> iterator = ServerHandlerWs.channelSvgMap.entrySet().iterator();
        while (iterator.hasNext()){
            Map.Entry<Channel, String> next = iterator.next();
            if(next.getValue().equals(id)){
                list.add(next.getKey());
            }
        }
        return list;
    }
}
